import React, { Component } from 'react';
import { Icon, Button, Table, Switch, Form, Input, Modal } from 'antd';
import AddAnswerInput  from './AddAnswerInput';
import QuestionGroupTable  from './QuestionGroupTable';

const FormItem = Form.Item;


const columns = [
  { title: '问题列表', dataIndex: 'question_name', key: 'question_name' },
  { title: '操作', dataIndex: '', key: 'x', render: () => <a href="#">Delete</a> },
];

class Manager extends Component {

  constructor(props) {
    super(props)
    this.state={
      tableLoading:this.props.questionsTableLoading,
      termsId:this.props.location.query
    }

    this.toggleTableLoading=this.toggleTableLoading.bind(this)
  }

  componentWillMount() {
    this.props.getOneTermByID(this.state.termsId);

  }
  toggleTableLoading(){
    this.setState({tableLoading:!this.state.tableLoading})
  }
  render() {
    const {answerData,tableLoading}=this.props.answers
    const { termsId}=this.state
    return (
      <div id="answers">
          <div className="message wrap">
          <h2><Icon type="exclamation-circle-o" />这里可以管理每个活动的相关问题</h2>
          </div>
          <div className="container-manager wrap">
            <div className="add-columns">
             <AddAnswerInput 
                termsId={termsId} 
                addOneTerm={this.props.addOneTerm}
                />
            </div>
            <div className="show-columns">
              <QuestionGroupTable answerData={answerData} tableLoading={tableLoading} />
            </div>
          </div>
      </div>
    )
  }
}



Manager = Form.create()(Manager);








export default Manager
